<?php namespace App\Models;

use Illuminate\Database\Eloquent\Model;

/**
 * Class Rater Group
 *
 * @package App\Models
 * @property int $id
 * @property int $rater_admin_id 评审管理员
 * @property string $name 名称
 * @property string $created_at
 * @property string $updated_at
 * @property-read \App\Models\User $raterAdmin
 * @property-read \Illuminate\Database\Eloquent\Collection|\App\Models\User[] $raters
 * @method static \Illuminate\Database\Query\Builder|\App\Models\RaterGroup whereId($value)
 * @method static \Illuminate\Database\Query\Builder|\App\Models\RaterGroup whereCreatedAt($value)
 * @method static \Illuminate\Database\Query\Builder|\App\Models\RaterGroup whereUpdatedAt($value)
 * @method static \Illuminate\Database\Query\Builder|\App\Models\RaterGroup whereRaterAdminId($value)
 * @method static \Illuminate\Database\Query\Builder|\App\Models\RaterGroup whereName($value)
 * @mixin \Eloquent
 */
class RaterGroup extends Model
{

    protected $fillable = ['name', 'rater_admin_id'];

    /**
     * 评审管理员
     * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
     */
    public function raterAdmin()
    {
        return $this->belongsTo(RaterAdmin::class, 'rater_admin_id');
    }

    /**
     * 评委
     * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany
     */
    public function raters()
    {
        return $this->belongsToMany(Rater::class, 'rater_group_user', 'rater_group_id', 'user_id');
    }
}